lambda_http 0.1.1

Rust API Gateway proxy event interfaces for AWS Lambda
Documentation

Enriches the lambda_runtime crate with http types targeting ALB and API Gateway proxy events.

Though ALB and API Gateway proxy events are separate Lambda triggers, they both share similar shapes that contextually map to an http request handler. From a application perspective the differences shouldn't matter. This crate abstracts over both using standard http types allowing you to focus more on your application while giving you to the flexibility to transparently use whichever http trigger suits your application's needs best.

Examples

use lambda_http::{lambda, IntoResponse, Request, RequestExt};
use lambda_runtime::{Context, error::HandlerError};

fn main() {
lambda!(hello)
}

fn hello(
request: Request,
_ctx: Context
) -> Result<impl IntoResponse, HandlerError> {
Ok(format!(
"hello {}",
request
.query_string_parameters()
.get("name")
.unwrap_or_else(|| "stranger")
))
}

You can also provide a closure directly to the lambda! macro

use lambda_http::{lambda, Request, RequestExt};

fn main() {
lambda!(
|request: Request, context| Ok(
format!(
"hello {}",
request.query_string_parameters()
.get("name")
.unwrap_or_else(|| "stranger")
)
)
)
}